package org.lei2j.org3;


/**
 * Created by lei2j on 2018/5/12.
 */
public abstract class Duck {

    private Quackable quackable;
    private Flyable flyable;

    public Duck() {
    }

    public Duck(Quackable quackable, Flyable flyable) {
        this.quackable = quackable;
        this.flyable = flyable;
    }

    public void swim(){
        System.out.println("swim");
    }

    public abstract void display();

    public void permFly(){
        if(flyable!=null){
            flyable.fly();
        }
    }

    public void permQuack(){
        if(quackable!=null){
            quackable.quack();
        }
    }

    public Quackable getQuackable() {
        return quackable;
    }

    public void setQuackable(Quackable quackable) {
        this.quackable = quackable;
    }

    public Flyable getFlyable() {
        return flyable;
    }

    public void setFlyable(Flyable flyable) {
        this.flyable = flyable;
    }
}
